package com.ctrip.ec.biz.image;

import com.ctrip.ec.biz.entity.image.ImageEntity;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

/**
 * Created by jiangzy on 2018/8/31.
 */
@Component
public class ImageFileUpload extends ImageUpload {


    @Override
    public String upload(String fileName, InputStream inputStream) {

//        String uploadDir = "upload/";
//
//
//        String filePath = request.getServletContext().getRealPath(uploadDir);
//
//
//        //ImageFileUpload.uploadFile(file.getBytes(), filePath, fileName);
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
//        Date now = new Date(System.currentTimeMillis());
//
//        String yearMonth = sdf.format(now);
//        filePath += sdf.format(now) + "/";
//
//        File targetFile = new File(filePath);
//        if (!targetFile.exists()) {
//            targetFile.mkdirs();
//        }
//
//        sdf = new SimpleDateFormat("yyyyMMdd");
//
//        String fileName = sdf.format(now) + "_" + String.format("%04d", num) + "." + type;
//
//
//
//        image.save(imageEntity);
//
//        FileOutputStream out = new FileOutputStream(filePath + fileName);
//        out.write(file.getBytes());
//        out.flush();
//        out.close();
        return null;
    }

    @Override
    public void delete(String url) {
        //return null;
    }
}
